package com.example.testlxr9096.adapter;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.testlxr9096.R;
import com.example.testlxr9096.bean.TitleItem;

import java.util.List;

public  class TitleItemAdapter extends RecyclerView.Adapter<TitleItemAdapter.ViewHolder> {

    private final List<TitleItem> list;




    public interface OnItemClickListener {
        void onItemClick(int position);
    }


    public TitleItemAdapter(List<TitleItem> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_title_layout, parent, false);
        return new ViewHolder(view);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, @SuppressLint("RecyclerView") int position) {
        TitleItem item = list.get(position);
        holder.Name.setText(item.getName());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        public TextView Name;


        public ViewHolder(View itemView) {
            super(itemView);
            Name = itemView.findViewById(R.id.tv_title);

        }
    }




}